// import { useAsync } from "./use-async";
import { useHttp } from "./http";
// import { useEffect } from "react";
// import { cleanObject } from "./index";
import { User } from "../types/user";
// import { Project } from "../types/project";
import { useQuery } from "react-query";
// import { cleanObjectPrivate } from "./project";

// export const useUser = (param?: Partial<User>) => {
//   const { run, ...result } = useAsync<User[]>()
//
//   const client = useHttp()
//   useEffect(() => {
//     run(client('/users', {data: cleanObject(param || {}) }))
//     // eslint-disable-next-line react-hooks/exhaustive-deps
//   }, [])
//   return {
//     ...result
//   }
// }
export const useUser = (param?: Partial<User>) => {
  const client = useHttp();
  return useQuery<User[]>(["users", param], () =>
    client("/users", { data: param || {} })
  );
};
